# -*- coding:utf-8 -*-
from pydantic import Field, BaseModel
from sqlalchemy import Column, Integer, String, DateTime, Enum, DECIMAL, Float, TEXT
from core.curd import Base, TimestampMixin


class SysMenu(Base, TimestampMixin):
    """
    测试表
    """
    __tablename__ = 'sys_menu'

    id = Column( Integer , nullable=False , autoincrement=True , primary_key=True , comment='id')
    pid = Column( Integer , comment='上级ID')
    name = Column( String(200) , comment='菜单名称')
    url = Column( String(200) , comment='组件')
    path = Column( String(200) , comment='路径')
    authority = Column( String(500) , comment='授权标识(多个用逗号分隔，如：sys:menu:list,sys:menu:save)')
    type = Column( Integer , comment='类型   0：菜单   1：按钮   2：接口')
    open_style = Column( Integer , comment='打开方式   0：内部   1：外部')
    icon = Column( String(50) , comment='菜单图标')
    sort = Column( Integer , comment='排序')
    version = Column( Integer , comment='版本号')
    deleted = Column( Integer , comment='删除标识  0：正常   1：已删除')
    creator = Column( Integer , comment='创建者')
    updater = Column( Integer , comment='更新者')


class CreateSysMenu(BaseModel):
    type: int = Field(comment="排序", default=0)
    name: str = Field(comment='名称', max_length=100)
    pid: int = Field(comment="上级目录", default=0)
    url: str = Field(comment='组件', max_length=100)
    authority: str = Field(comment='授权标识', max_length=100)
    sort: int = Field(comment="排序", default=0)
    icon: str = Field(comment='岗位编码', max_length=100)
    open_style: int = Field(comment="排序", default=0)


class UpdateSysMenu(BaseModel):
    id: int = Field(comment='id')
    type: int = Field(comment="排序", default=0)
    name: str = Field(comment='名称', max_length=100)
    pid: int = Field(comment="上级目录", default=0)
    url: str = Field(comment='组件', max_length=100)
    authority: str = Field(comment='授权标识', max_length=100)
    sort: int = Field(comment="排序", default=0)
    icon: str = Field(comment='岗位编码', max_length=100)
    open_style: int = Field(comment="排序", default=0)
